package com.hxgis.common.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

/**
 * json转换工具类
 */
public class JsonUtil<T> {

    private JsonUtil(){

    }


    public static String beanToString(Object object) throws JsonProcessingException {
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper.writeValueAsString(object);
    }

    public static <T> T stringToBean(String string, Class<T> clazz) throws IOException{
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper.readValue(string,clazz);
    }



}
